package com.yixin.mapper;

import com.yixin.entity.Permission;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PermissionMapper {
    @Insert("insert into permission(per_key, per_name, module, is_del, create_time, update_time) values(#{perKey}, #{perName}, #{module}, #{isDel}, #{createTime}, #{updateTime})")
    void add(Permission permission);

    @Update("update permission set per_key = #{perKey}, per_name = #{perName}, module = #{module}, update_time = #{updateTime} where id = #{id}")
    void update(Permission permission);

    @Update("update permission set is_del = 1 where id = #{id}")
    void deleteById(Integer id);

    @Select("select id, per_key, per_name, module, is_del, create_time, update_time from permission where is_del = 0 order by id")
    List<Permission> findAll();
}
